package com.thprojects.myphotomemories.model;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

public class Photo implements Parcelable{
	
	public static final int NO_WEB_ID = -1;
	
	int mId;
	int mWebId;
	String mPath;
	String mName;
	String mCaption;
	String mLocation;
	boolean mShared;
	boolean mNewDetailChanges;
	boolean mNewImageChanges;
	Album mAlbum;
	List<Contact> mContacts;
	
	public Photo (int id, int webId, String path, String name, String caption, String location, boolean shared, boolean newDetailChanges, boolean newImageChanges, Album album, List<Contact> contacts){
		mId = id;
		mPath = path;
		mName = name;
		mCaption = caption;
		mLocation = location;
		mShared = shared;
		mNewDetailChanges = newDetailChanges;
		mNewImageChanges = newImageChanges;
		mAlbum = album;
		mContacts = contacts;
	}
	
	public Photo(Parcel in){
		mId = in.readInt();
		mPath = in.readString();
		mName = in.readString();
		mCaption = in.readString();
		mLocation = in.readString();
		mShared = in.readByte() == 1;
		mNewDetailChanges = in.readByte() == 1;
		mNewImageChanges = in.readByte() == 1;
		mAlbum = in.readParcelable(Album.class.getClassLoader());
		mContacts = new ArrayList<Contact>(); 
		in.readTypedList(mContacts, Contact.CREATOR);
	}

	public int getId(){
		return mId;
	}
	
	public int getWebId(){
		return mWebId;
	}
	
	public void setWebId(int webId){
		mWebId = webId;
	}
	
	
	/**
	 * @return the mPath
	 */
	public String getPath() {
		return mPath;
	}

	/**
	 * @param mPath the mPath to set
	 */
	public void setPath(String mPath) {
		this.mPath = mPath;
	}

	/**
	 * @return the mName
	 */
	public String getName() {
		return mName;
	}

	/**
	 * @param mName the mName to set
	 */
	public void setName(String mName) {
		this.mName = mName;
	}

	/**
	 * @return the mCaption
	 */
	public String getCaption() {
		return mCaption;
	}

	public List<Contact> getContacts(){
		return mContacts;
	}
	
	public void setContacts(List<Contact> contacts){
		mContacts = contacts;
	}
	
	/**
	 * @param mCaption the mCaption to set
	 */
	public void setCaption(String mCaption) {
		this.mCaption = mCaption;
	}

	/**
	 * @return the mLocation
	 */
	public String getLocation() {
		return mLocation;
	}

	/**
	 * @param mLocation the mLocation to set
	 */
	public void setLocation(String mLocation) {
		this.mLocation = mLocation;
	}

	/**
	 * @return the mShared
	 */
	public boolean isShared() {
		return mShared;
	}

	/**
	 * @param mShared the mShared to set
	 */
	public void setShared(boolean mShared) {
		this.mShared = mShared;
	}

	/**
	 * @return the mNewChanges
	 */
	public boolean hasNewDetailChanges() {
		return mNewDetailChanges;
	}

	/**
	 * @param mNewChanges the mNewChanges to set
	 */
	public void setNewDetailChanges(boolean mNewDetailChanges) {
		this.mNewDetailChanges = mNewDetailChanges;
	}
	
	/**
	 * @return the mNewChanges
	 */
	public boolean hasNewImageChanges() {
		return mNewDetailChanges;
	}

	/**
	 * @param mNewChanges the mNewChanges to set
	 */
	public void setNewImageChanges(boolean mNewDetailChanges) {
		this.mNewDetailChanges = mNewDetailChanges;
	}

	/**
	 * @return the mAlbum
	 */
	public Album getAlbum() {
		return mAlbum;
	}

	/**
	 * @param mAlbum the mAlbum to set
	 */
	public void setAlbum(Album mAlbum) {
		this.mAlbum = mAlbum;
	}

	public int describeContents() {
		return 0;
	}

	public void writeToParcel(Parcel out, int arg1) {
		out.writeInt(mId);
		out.writeString(mPath);
		out.writeString(mName);
		out.writeString(mCaption);
		out.writeString(mLocation);
		out.writeByte((byte)(mShared ? 1 : 0));
		out.writeByte((byte)(mNewDetailChanges ? 1 : 0));
		out.writeByte((byte)(mNewImageChanges ? 1 : 0));
		out.writeParcelable(mAlbum, 0);
		out.writeTypedList(mContacts);
	}
	
	// this is used to regenerate your object. All Parcelables must have a CREATOR that implements these two methods
    public static final Parcelable.Creator<Photo> CREATOR = new Parcelable.Creator<Photo>() {
        public Photo createFromParcel(Parcel in) {
            return new Photo(in);
        }

        public Photo[] newArray(int size) {
            return new Photo[size];
        }
    };
	
}
